#include <GL\freeglut.h>
#include "Camera.h"


Camera::Camera(float xRot, float yRot, float xPos,float yPos, float zPos)
{
	rot = new vec3(xRot,yRot,0);
	place = new vec3(xPos,yPos,zPos);
}

void Camera::rotation()
{
	glRotatef(rot->x,1.0,0.0,0.0);
	glRotatef(rot->y,0.0,1.0,0.0);
}


void Camera::translation(AreaMap* map)
{
	glTranslatef(-place->x, -place->y +-map->heightAt(place->x,place->z),-place->z); //translate to the position of our camera
}

void Camera::rotate(float delta,int axis)
{
	if (axis <= 0)
		rot->x += delta;
	else if (axis == 1)
		rot->y += delta;
	else if (axis >= 2)
		rot->z += delta;
}

void Camera::move(float delta,int axis)
{
	if (axis <= 0)
		place->x += delta;
	else if (axis == 1)
		place->y += delta;
	else if (axis >= 2)
		place->z += delta;
}

void Camera::clamp(int width, int length)
{
	if (place->x < 0)
		place->x = 0;
	else if (place->x > width)
		place->x = width;

	if (place->z < 0)
		place->z = 0;
	else if (place->z > length)
		place->z = length;
}

Camera::~Camera(void)
{
}
